﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;

namespace wordsMemory
{   
   
    public class WordService
    {
        string connectionString = "Server = 拯救者; user=sa;pwd=1;Database=translator;pooling=false";
        public WordService() { }
        public List<Word> GetWords() {
            try
            {
                using (IDbConnection db = new SqlConnection(connectionString))
                {
                    string sql = "select * from word";
                    return db.Query<Word>(sql).ToList();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("单词获取异常！", ex);
            }
        }
    }

}

